package com.hengxinguotong.zhihuichengjian.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;

import com.hengxinguotong.zhihuichengjian.R;
import com.hengxinguotong.zhihuichengjian.treeview.RecyclerAdapter;
import com.hengxinguotong.zhihuichengjian.widget.font.HXTextView;
import com.hengxinguotong.zhihuichengjian.bean.Message;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * @CopyRight 恒信国通信息科技
 * @Author WuLei
 * @Date 2018/12/19
 */

public class HomeMessageAdapter extends RecyclerAdapter<Message, HomeMessageAdapter.MessageViewHolder> {

    public HomeMessageAdapter(Context context, List<Message> dataList) {
        super(context, dataList);
    }

    @Override
    public MessageViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = View.inflate(context, R.layout.item_home_message, null);
        return new MessageViewHolder(view);
    }

    @Override
    public void onBindViewHolder(MessageViewHolder holder, int position) {
        holder.bindData(position);
    }

    public class MessageViewHolder extends RecyclerAdapter.BaseViewHolder<Message>{
        @BindView(R.id.item_title)
        HXTextView item_title;
        @BindView(R.id.item_time)
        HXTextView item_time;

        public MessageViewHolder(View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
        }

        @Override
        public void bindData(int position) {
            Message message = dataList.get(position);
            item_title.setText(message.getContent());
            item_time.setText(message.getCreateTime());
        }
    }
}
